package logic

import (
	"context"
	"errors"
	"product_server/dao/dao_redis"
	product "product_server/proto"
)

// DelCarProduct 从购物车中移除商品
func (p *ProductServer) DelCarProduct(ctx context.Context, req *product.DelCarProductRequest) (*product.DelCarProductResponse, error) {
	if !dao_redis.GetCatExists(req.Uid, req.ProductId) {
		return nil, errors.New("购物车商品不存在")
	}
	err := dao_redis.DelCarProduct(req.Uid, req.ProductId)
	if err != nil {
		return nil, err
	}
	return &product.DelCarProductResponse{Success: true}, nil
}
